/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bolao.util;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author 
 */
public class ServiceUtil {

    private static final String CONTEXTO_SISTEMA = "Bolao2.0";

    public static <T> T lookupEjbSessionBean(Class<T> t) {
        try {
            Context c = new InitialContext();
            return (T) c.lookup("java:global/" + CONTEXTO_SISTEMA + "/" + t.getSimpleName() + "!" + t.getName());
        } catch (NamingException ne) {
            throw new RuntimeException("Erro ao fazer o lookup do session bean: " + ne.getMessage(), ne);
        }
    }
}
